package site.yunnong.atvris.admin.controller;

import java.util.Arrays;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import site.yunnong.atvris.common.api.Page;
import site.yunnong.atvris.dao.domain.NewsComment;
import site.yunnong.common.entity.NewsCommentEntity;
import site.yunnong.common.service.NewsCommentService;
import site.yunnong.common.utils.PageUtils;
import site.yunnong.common.utils.R;



/**
 * 动态评论
 *
 * @author zhangjinghao
 * @email jhzhang9102@163.com
 * @date 2021-07-09 23:45:37
 */
@RestController
@RequestMapping("/news-comment")
public class NewsCommentController {

    /**
     * 列表
     */
    @RequestMapping("/list")
    public ResultVO list(@RequestParam NewsCommentQueryParam param){
        Page page = commentsService.queryPage(params);
        return ResultVO.success(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public ResultVO info(@PathVariable("id") Long id){
		NewsComment newsComment = commentsService.getById(id);
        return ResultVO.success(newsComment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("common:newscomment:save")
    public R save(@RequestBody NewsCommentEntity newsComment){
		commentsService.save(newsComment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("common:newscomment:update")
    public R update(@RequestBody NewsCommentEntity newsComment){
		commentsService.updateById(newsComment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("common:newscomment:delete")
    public R delete(@RequestBody Long[] ids){
		commentsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
